package com.example.nettydemo.service.impl;

import com.example.nettydemo.dto.Wallet;
import com.example.nettydemo.dto.mock.User;
import com.example.nettydemo.service.WalletService;
import com.example.nettydemo.util.MockData;
import org.springframework.stereotype.Service;

/**
 * @author WZW
 * @date 2020/5/9
 */
@Service
public class WalletServiceImpl implements WalletService {

    /*@Autowired
    private WalletMapper walletMapper;*/

    @Override
    public int getBalanceByUsername(String username) {
//        return getOneByUsername(username).getMoney();
        return MockData.USER_LIST.stream().
                filter(user -> user.getUsername().equals(username)).
                mapToInt(User::getBalance).
                findFirst().
                orElse(1000);
//        return 100.0;
    }

    @Override
    public Wallet getOneByUsername(String username) {
//        return walletMapper.selectOne(Wrappers.<Wallet>lambdaQuery().eq(Wallet::getUsername,username));
        return new Wallet();
    }
}
